<?php

class ValveController extends Controller
{
    public $layout = '//layouts/main';
    public $defaultAction = 'manage';

    public function actionManage()
    {
        session_write_close();
        $model = new MsggItemValve();
        if (isset($_GET['MsggItemValve'])) {
            $model->attributes = $_GET['MsggItemValve'];
        }
        $this->render('manage', array(
            'model' => $model
        ));
    }

    public function actionClean($pre,$type)
    {
        if (Yii::app()->request->isPostRequest) {
                if (MsggItemValve::clean($pre,$type)) {
                    echo 'Success';
                } else {
                    echo 'Error:DB Delete Failure!';
                }
        } else
            throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
    }

    public function colRevise($data, $row, $c)
    {
        $name = $c->name;
        switch ($name) {
            case 'cnname':
                $html = $data['cnname'];
                return $html;
                break;
            case 'type':
                $html = $data['type'];
                return $html;
                break;
            case 'info':
                $html = '';
                $html .= '【是否超频】:'.($data['isoverclock']?'yes':'no').'</br>';
                $html .= '【执行情况】:'.($data['total']).'</br>';
                $html .= '【阈值】:'.($data['limit']).'</br>';
                return $html;
                return $html;
                break;

        }
    }
}